<template>
  <div class="components-input-demo-presuffix">
    <!---->
    <a-input @click="openModal" placeholder="请点击选择产品" v-model="pid" readOnly :disabled="disabled">
      <a-icon slot="prefix" type="cluster" title="部门选择控件"/>
    </a-input>

    <j-select-depart-modal
      ref="innerDepartSelectModal"
      :modal-width="modalWidth"
      :multi="multi"
      :rootOpened="rootOpened"
      @ok="handleOK"
      @initComp="initComp"/>
  </div>
</template>

<script>


  import JSelectDepartModal from './modal/JSelectProductModal'

  export default {
    name: 'JSelectDepart',
    components:{
      JSelectDepartModal
    },
    props:{
      modalWidth:{
        type:Number,
        default:1200,
        required:false
      },
      multi:{
        type:Boolean,
        default:false,
        required:false
      },
      rootOpened:{
        type:Boolean,
        default:true,
        required:false
      },
      value:{
        type:String,
        required:false
      },
      disabled:{
        type: Boolean,
        required: false,
        default: false
      },
      // 自定义返回字段，默认返回 id
      customReturnField: {
        type: String,
        default: 'id'
      }
    },
    data(){
      return {
        visible:false,
        confirmLoading:false,
        pid:"",
       
       
      }
    },
  
  
    methods:{
      initComp(departNames){
        this.departNames = departNames
      },
      openModal(){
        this.$refs.innerDepartSelectModal.show()
      },
      handleOK(val) {
         this.pid = val
         this.$emit("change", val)

        // let value = ''
        // if (!rows && rows.length <= 0) {
        //   this.departNames = ''
        //   this.pids = ''
        // } else {
        //   value = rows.map(row => row[this.customReturnField]).join(',')
        //   this.departNames = rows.map(row => row['departName']).join(',')
        //   this.pids = idstr
        // }
        // this.$emit("change", value)
      },
      getDepartNames(){
        return this.departNames
      },
 
       initDictConfig(){
      },
      serviceBtn(val){
        console.log(val)
        this.$router.push({path:'/internet/ServiceCapabilityList',query: {id:val.id}})
      }
    },
    model: {
      prop: 'value',
      event: 'change'
    }
  }
</script>

<style scoped>
  @import '~@assets/less/common.less';

  .components-input-demo-presuffix .anticon-close-circle {
    cursor: pointer;
    color: #ccc;
    transition: color 0.3s;
    font-size: 12px;
  }
  .components-input-demo-presuffix .anticon-close-circle:hover {
    color: #f5222d;
  }
  .components-input-demo-presuffix .anticon-close-circle:active {
    color: #666;
  }
</style>